package org.qpcr.community.project.model.entity;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.Comment;
import org.hswebframework.ezorm.rdb.mapping.annotation.DefaultValue;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.api.crud.entity.RecordCreationEntity;
import org.hswebframework.web.api.crud.entity.RecordModifierEntity;
import org.hswebframework.web.crud.annotation.EnableEntityEvent;
import org.hswebframework.web.crud.generator.Generators;
import org.hswebframework.web.validator.CreateGroup;

import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.Table;
import javax.validation.constraints.NotBlank;

@Getter
@Setter
@Table(name = "biz_carrier_usage_record")
@Comment("载体使用记录表")
@EnableEntityEvent
public class CarrierUsageRecordInstanceEntity extends GenericEntity<String> implements RecordCreationEntity, RecordModifierEntity {

    @Override
    @GeneratedValue(generator = Generators.SNOW_FLAKE)
    @NotBlank(message = "ID不能为空", groups = CreateGroup.class)
    @Schema(description = "ID")
    public String getId() {
        return super.getId();
    }

    @Column(name = "code", length = 64)
    @Schema(description = "载体编号")
    public String code;

    @Column(name = "name", length = 64)
    @Schema(description = "载体名称")
    private String name;

    @Column(name = "item", length = 64)
    @Schema(description = "检测项")
    public String item;

    @Column(name = "item_code", length = 64)
    @Schema(description = "检测项编码")
    private String itemCode;

    @Column(name = "sequence_name", length = 100)
    @Schema(description = "序列名称")
    public String sequenceName;

    @Column(name = "sequence_code", length = 64)
    @Schema(description = "序列编码")
    private String sequenceCode;

    @Column(name = "usager", length = 100)
    @Schema(description = "使用人")
    public String usager;

    @Column(name = "usage_time")
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(
            description = "使用时间"
            , accessMode = Schema.AccessMode.READ_ONLY
    )
    private Long usageTime;

    @Column(name = "creator_id", updatable = false)
    @Schema(
        description = "创建者ID(只读)"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private String creatorId;

    @Column(name = "creator_name", updatable = false)
    @Schema(
            description = "创建者名称(只读)"
            , accessMode = Schema.AccessMode.READ_ONLY
    )
    private String creatorName;

    @Column(name = "create_time", updatable = false)
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(
        description = "创建时间(只读)"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private Long createTime;

    @Column
    @DefaultValue(generator = Generators.CURRENT_TIME)
    @Schema(
        description = "修改时间"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private Long modifyTime;

    @Column(length = 64)
    @Schema(
        description = "修改人ID"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private String modifierId;

    @Column(length = 64)
    @Schema(
        description = "修改人名称"
        , accessMode = Schema.AccessMode.READ_ONLY
    )
    private String modifierName;
}
